package min.chapter.three;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class ContextAwareImplement implements ContextAware, BeanNameAware, ApplicationContextAware {
	private  String  beanName;
	private ApplicationContext  context;
	@Override
	public  void  setBeanName(String beanName)  {
	System.out.println("setBeanName(...) 실행..."+this.beanName);
	this.beanName = beanName;
	}
	
	@Override
//  ApplicationContext를  빈에  전달
public void setApplicationContext(ApplicationContext context) throws BeansException {
System.out.println("setApplicationContext(...) 실행..."+this.context);
this.context =  context;
}
	
	@Override
	public  void  lifeMessage()  {
	System.out.println("life 비지니스 로직 수행 중...");
	OtherContextAware other =  (OtherContextAware)  context.getBean("otherBean");
	other.otherMessage();
}
}

